/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package mathma.core.bool;

import mathma.core.expr.Expression;

import mathma.core.form.UnaryExpression;

/**
 * Logical negation.  Returns true if and only if the operand evaluates to
 * false.
 *
 * @since 0.2.4
 * @author Ethan Levine
 */
public class NotExpression
        extends UnaryExpression<BooleanValue, BooleanValue> {

    /**
     * Creates a new NotExpression.
     *
     * @param operand the operand of the negation.
     */
    public NotExpression(Expression<BooleanValue> operand) {
        super(BooleanValue.Type, operand);
    }

    /**
     * Evaluates this negation.  Returns true if and only if the operand
     * evaluates to false.
     * 
     * @return the result of this negation.
     */
    public BooleanValue evaluate() {
        return getOperand().evaluate();
    }

    public NotExpression newUnaryExpression(Expression<BooleanValue> operand) {
        return new NotExpression(operand);
    }
}
